/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mobicom;

import SQL.DAOFactory;
import SQL.ReplyDAO;
import SQL.Word;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
 *
 * @author Julian
 */
@WebService(serviceName = "Service")
public class Service {

    /**
     * This is a sample web service operation
     */
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        return "Hello " + txt + " !";
    }
    
    @WebMethod(operationName = "addWord")
        public String addWord(@WebParam(name = "category") String category, @WebParam(name = "answer") String answer, @WebParam(name = "keyWord") String nKeyword) {
         DAOFactory myDAOFactory = DAOFactory.getInstance(DAOFactory.MYSQL);
         ReplyDAO stockDAO = myDAOFactory.createReplyDAO();
         Word w = new Word();
         w.setAnswer(answer);
         w.setCategory(category);
         w.setKeyword(nKeyword);
         stockDAO.addWord(w);
         return "Something";
       }
    @WebMethod(operationName = "getAnswer")
    public String getReply(@WebParam(name = "keyword")String keyword, @WebParam(name = "category")String category) {
         DAOFactory myDAOFactory = DAOFactory.getInstance(DAOFactory.MYSQL);
         ReplyDAO stockDAO = myDAOFactory.createReplyDAO();
         //System.out.println("RETURN BY getReply: "+stockDAO.getReply(keyword, category));
         return stockDAO.getReply(keyword, category);
       }
}
